<!--  -->
<template>
  <div>
      <el-form :inline="true" class="demo-form-inline"
      label-width="100px">
          <el-form-item label="创建时间">
                <el-date-picker 
                value-format="yyyy-MM-dd HH:mm:ss"
                v-model="baseRepair.createDate"
                type="datetime"
                ></el-date-picker>
          </el-form-item>
        <el-form-item label="状态">
            <el-select placeholder="请选择" v-model="baseRepair.childStatus">
                <el-option label="已报修" value="已报修"></el-option>
                <el-option label="良好" value="良好"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item >
                <el-button @click="query" type="primary">查询</el-button> &nbsp;
                <el-button @click="reset" type="primary">重置</el-button>  
          </el-form-item>
      </el-form>


      <el-table :data="baseList" stripe border>
            <el-table-column type="index"  label="序号" width="100px">
                <template slot-scope="scope">
                    <span>
                        {{ scope.$index + (baseRepair.pageIndex - 1) * baseRepair.pageSize+ 1 }}
                    </span>
                </template>
            </el-table-column>
            <el-table-column label="基建地址" prop="address"></el-table-column>
            <el-table-column label="基建名" prop="baseName"></el-table-column>
            <el-table-column label="设备名称" prop="childName"></el-table-column>  
            <el-table-column label="设备编号" prop="stockNo"></el-table-column>
            <el-table-column label="问题描述" prop="describe"></el-table-column>
            <el-table-column label="创建时间" prop="createDate" width="200"></el-table-column>
            <el-table-column label="状态" prop="childStatus"></el-table-column>
            <el-table-column label="操作" fixed="right" width="300px">
              <template slot-scope="scope">
                <el-button @click="updateStatu(scope.row.id)" type="primary" v-if="scope.row.childStatus!='良好'" >完成检修</el-button>
                <el-button @click="delet(scope.row.id)" type="warning"  >删除</el-button>                   
              </template>
          </el-table-column>
      </el-table>

    <el-pagination
        background
        layout="prev, pager, next"
        :total="total"
        :page-size="5"
        @current-change="change"
    >

    </el-pagination>

    <!-- <el-dialog
        title="提示"
        :visible.sync='deleteDialog'
        width="30%"
    >
      <span>确定要删除吗？</span>
        <span slot="footer" class="dialog-footer">
            <el-button @click="deleteDialog = false">取 消</el-button>
            <el-button type="primary" @click="delete">确 定</el-button>
        </span>
    </el-dialog> -->
  </div>
</template>

<script>
export default {
  data () {
    return {
        baseList:[],
        baseRepair:{
            createDate:'',
            endDate:'',
            pageIndex:'1',
            pageSize:'5',
            childStatus:'',
            baseName:'',
        },
        total:null       
    }
  },
  methods:{
      showList(){
          
          this.axios.post("/baseRepair/List",this.baseRepair).then(res=>{
              if(res.data.code==200){
                  this.baseList=res.data.data.list;
                  this.total=res.data.data.total;
                  this.baseList.pageIndex=res.data.data.pageNum;
              }
          })
      },
      updateStatu(id){
          this.axios.get("/baseRepair/updateStatus",{
              params:{
                  deviceId:id
              }
          }).then(res=>{
                if(res.data.code==200){
                    this.showList();
                    this.$message({
                        message:"修改成功",
                        type:'success'
                    })
                }
          })
      },
      delet(id){
        this.$confirm("确认删除吗？",'提示',{
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
        }).then(()=>{
            this.axios.get("/baseRepair/delete",{
              params:{
                  id:id
              }
          }).then(res=>{
              if(res.data.code==200){
                this.$message({
                    type:"type",
                    message:'删除成功'
                })
                this.showList();
              }else{
                  this.$message({
                    type:"type",
                    message:'删除失败'
                  })
              }
          })
        }).catch(()=>{
         
        })

      },
      showDeleteDialog(){

      },
      query(){
          this.showList();
      },
      change(currentPage){
          this.baseRepair.pageIndex=currentPage;
          this.showList();
      },
      reset(){
          this.baseRepair.createDate='';
          this.baseRepair.childStatus='';
          this.baseRepair.baseName='';
          this.showList();
          
      }
  },
  created(){
      this.showList();
  }
  

}
</script>

<style>
div{
  
}
</style>
